/**
 * @program: LeetCode
 * @description: LeetCode : 746. 使用最小花费爬楼梯
 * @author: WXY
 * @create: 2023-01-25 19:44
 * @Version 1.0
 **/
public class Num746_minCostClimbingStairs {
    public static int minCostClimbingStairs1(int[] arr) {
        int[] dp = new int[arr.length + 1];
        dp[0] = 0;
        dp[1] = 0;
        for (int i = 2; i <= arr.length; i++) {
            dp[i] = Math.min(dp[i - 1] + arr[i - 1], dp[i - 2] + arr[i - 2]);
        }
        return dp[arr.length];
    }

    public static int minCostClimbingStairs(int[] arr) {
        int[] dp = new int[arr.length + 1];
        dp[0] = 0;
        dp[1] = 0;
        for (int i = 2; i < arr.length; i++) {
            dp[i] = Math.min(arr[i - 1] + dp[i - 1], arr[i - 2] + dp[i - 2]);
        }
        return dp[arr.length ];
    }
}
